const express = require('express');
const path = require('path');
const app = express();

// 通过app.use()方法使用中间件
// express.static这个中间件的作用是处理静态资源
app.use(express.static(path.join(__dirname, 'public')));

app.get('/', (req,res) => {
  console.log('现在，前端在向我们发起请求');
  // console.log(1, req.app);
  // console.log(2, req.baseUrl);
  // console.log(3, req.body);
  // console.log(4, req.hostname);
  // console.log(5, req.originalUrl);
  // console.log(6, req.params);
  // console.log(7, req.query);
  // console.log(8, req.protocol);
  // console.log(9, req.route);
  res.send('hello')
})

let sever = app.listen(3000, '127.0.0.1', () => {
  let host = sever.address().address;
  let port = sever.address().port;
  console.log('OK!', host, port)
})